package model.collisions2d;

import java.util.ArrayList;
import java.util.Collection;

public class MultipleBoxMask {
	private final ArrayList<BoxMask> masks = new ArrayList<BoxMask>();
	
	public MultipleBoxMask(BoxMask mask){
		masks.add(mask);
	}
	
	public MultipleBoxMask(Collection<BoxMask> masks){
		this.masks.addAll(masks);
	}
	
	public boolean isInsideMask(double x,double y){
		boolean result = false;
		for(BoxMask mask: masks){
			if(!result && mask.isInsideMask(x,y)){
				result = true;
			}
		}
		return result;
	}
	
	public boolean isInsideMask(BoxMask m){
		boolean result = false;
		for(BoxMask mask: masks){
			if(!result && mask.isInsideMask(m)){
				result = true;
			}
		}
		return result;
	}
	
	public boolean isInsideMask(BoxMask m, double xoffset, double yoffset){
		boolean result = false;
		for(BoxMask mask: masks){
			if(!result && mask.isInsideMask(m,xoffset,yoffset)){
				result = true;
			}
		}
		return result;
	}
	
	public boolean isInsideMask(MultipleBoxMask mbm){
		boolean result = false;
		for(BoxMask mask: masks){
			if(!result && mbm.isInsideMask(mask)){
				result = true;
			}
		}
		return result;
	}
	
	public boolean isInsideMask(MultipleBoxMask mbm,double xoffset,double yoffset){
		boolean result = false;
		for(BoxMask mask: masks){
			if(!result && mbm.isInsideMask(mask,xoffset,yoffset)){
				result = true;
			}
		}
		return result;
	}
}
